package com.junmo.common.sms.properties;

import com.junmo.common.constant.GlobalConstants;
import com.junmo.common.util.StringUtils;

/**
 * 阿里云短信模板
 */
public enum DySmsEnum {

    /**
     * 注册短信模板
     **/
    REGISTER_SMS_TEMPLATE("SMS_225387583", "JUNMO", "code", GlobalConstants.REGISTER),
    /**
     * 登录短信模板
     **/
    LOGIN_SMS_TEMPLATE("SMS_225387583", "JUNMO", "code",GlobalConstants.LOGIN),
    /**
     * 忘记密码短信模板
     **/
    FORGET_PASSWORD_SMS_TEMPLATE("SMS_225387583", "JUNMO", "code",GlobalConstants.FORGET_PASSWORD);

    /**
     * 短信模板编码
     */
    private String templateCode;
    /**
     * 签名
     */
    private String signName;
    /**
     * 短信模板必需的数据名称，多个key以逗号分隔，此处配置作为校验
     */
    private String keys;
    /**
     * 模版名称
     */
    private String name;

    DySmsEnum(String templateCode, String signName, String keys, String name) {
        this.templateCode = templateCode;
        this.signName = signName;
        this.keys = keys;
        this.name = name;
    }

    public String getTemplateCode() {
        return templateCode;
    }

    public void setTemplateCode(String templateCode) {
        this.templateCode = templateCode;
    }

    public String getSignName() {
        return signName;
    }

    public void setSignName(String signName) {
        this.signName = signName;
    }

    public String getKeys() {
        return keys;
    }

    public void setKeys(String keys) {
        this.keys = keys;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static DySmsEnum toEnum(String templateCode) {
        if (StringUtils.isEmpty(templateCode)) {
            return null;
        }
        for (DySmsEnum item : DySmsEnum.values()) {
            if (item.getTemplateCode().equals(templateCode)) {
                return item;
            }
        }
        return null;
    }
}

